package com.yixun.service.impl;

import com.yixun.entity.SettingLogs;
import com.yixun.entity.YxUser;
import com.yixun.mapper.LogSetMapper;
import com.yixun.service.LogSetService;
import com.yixun.util.DateUtil;
import com.yixun.util.FormatUtil;
import org.springframework.stereotype.Service;

@Service
public class LogSetServiceImpl implements LogSetService {

    private final LogSetMapper logSetMapper;

    public LogSetServiceImpl(LogSetMapper logSetMapper) {
        this.logSetMapper = logSetMapper;
    }

    @Override
    public void insertSettingLogs(String oper_type, String oper_name, String objJson, YxUser sessionUser) {

        if (null != sessionUser) {
            SettingLogs settingLogs = new SettingLogs();
            settingLogs.setAudit_id(new FormatUtil().getUUID());
            settingLogs.setUser_id(sessionUser.getUser_id());
            settingLogs.setDept_id(sessionUser.getDept_id());
            settingLogs.setUser_name(sessionUser.getUser_name());
            settingLogs.setAudit_des("[" + oper_type + "]" + oper_name + "ID为： " + objJson + " 的数据");
            settingLogs.setAudit_time(DateUtil.getCurrentDateTime());
            settingLogs.setIp(sessionUser.getIp());
            logSetMapper.insertSettingLogs(settingLogs);
        }

    }
}
